<template>
  <div class="redirect-container">
    <div class="loading">
      <el-icon class="is-loading" :size="40">
        <Loading />
      </el-icon>
      <p>页面跳转中...</p>
    </div>
  </div>
</template>

<script setup lang="ts">
import { onBeforeMount } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { Loading } from '@element-plus/icons-vue'

const route = useRoute()
const router = useRouter()

onBeforeMount(() => {
  const { params, query } = route
  const { path } = params as { path: string }
  
  // 重定向到目标路径
  router.replace({ path: '/' + path, query })
})
</script>

<style lang="scss" scoped>
.redirect-container {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--el-bg-color-page);

  .loading {
    text-align: center;
    color: var(--el-text-color-secondary);

    .el-icon {
      margin-bottom: 16px;
      color: var(--el-color-primary);
    }

    p {
      margin: 0;
      font-size: 14px;
    }
  }
}
</style>
